package com.study.spaoplog.base;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * @author study
 * @version 1.0
 * @date 2021/6/9 11:03
 */
@Slf4j
public class ShutDownHook extends Thread {

    private ConfigurableApplicationContext applicationContext;

    public ShutDownHook(ConfigurableApplicationContext applicationContext) {
        super();
        this.applicationContext = applicationContext;
    }

    @Override
    public void run() {
        log.info("Start clean the login info.");
        //在系统快要关闭时，获取Bean实例，做一下善后工作
        /*final CuratorFramework zkClient = applicationContext.getBean("zkClient", CuratorFramework.class);
        System.out.println(StringUtils.center("关闭zkClient", 51, "*"));
        CloseableUtils.closeQuietly(zkClient);
        applicationContext.close();*/
        log.info("Socket server shutdown");
    }
}
